home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Load action file *)
- (* *)
- (* Copyright 1990, 1991, 1992 by H. Roy Engehausen. All rights reserved. *)
- (* *)
- (*===========================================================================*)
-
- (*=========================================================================*)
- (* Main line *)
- (*=========================================================================*)
-
- BEGIN;
-
- {$IFDEF DEBUG1}
- WRITELN('Action load start');
- DELAY(1000);
- {$ENDIF}
-
- (*-----------------------------------------------------------------------*)
- (* Get right options *)
- (*-----------------------------------------------------------------------*)
-
- execute_load := POS(execute_who, 'LF ' + #1) > 0;
- execute_make := POS(execute_who, 'MF ') > 0;
- execute_clean := POS(execute_who, 'C ') > 0;
-
- (*-----------------------------------------------------------------------*)
- (* See if we can run. *)
- (*-----------------------------------------------------------------------*)
-
- IF execute_load AND bbs_busy AND (execute_who <> #1) THEN
- BEGIN;
- cannot_do_this(message_other_active);
- EXIT;
- END;
-
- {$IFDEF DEBUG1}
- WRITELN('Action load ready');
- DELAY(1000);
- {$ENDIF}
-
- (*-----------------------------------------------------------------------*)
- (* Lock the action area *)
- (*-----------------------------------------------------------------------*)
-
- (*-----------------------------------------------------------------------*)
- (* Tell user started *)
- (*-----------------------------------------------------------------------*)
-
- send_tnc_data_str('Action processing is started -- Please wait.' + cr);
-
- (*-----------------------------------------------------------------------*)
- (* Obtain the interrupt lock *)
- (*-----------------------------------------------------------------------*)
-
- get_semaphore(semaphore_interrupts, sem_exclusive, FALSE);
-
- (*-----------------------------------------------------------------------*)
- (* Free old action data *)
- (*-----------------------------------------------------------------------*)
-
- IF execute_load THEN
- free_action;
-
- (*-----------------------------------------------------------------------*)
- (* Free the lock *)
- (*-----------------------------------------------------------------------*)
-
- free_semaphore(semaphore_interrupts);
-
- (*-----------------------------------------------------------------------*)
- (* Open action file for read *)
- (*-----------------------------------------------------------------------*)
-
- {$IFDEF DEBUG1}
- WRITELN('Action load name check');
- DELAY(1000);
- {$ENDIF}
-
- IF opt_block.action_fn = '' THEN
- EXIT;
-
- (*-----------------------------------------------------------------------*)
- (* Obtain the interrupt lock *)
- (*-----------------------------------------------------------------------*)
-
- get_semaphore(semaphore_interrupts, sem_exclusive, FALSE);
-
- (*-----------------------------------------------------------------------*)
- (* Open action file for read *)
- (*-----------------------------------------------------------------------*)
-
- {$IFDEF DEBUG1}
- WRITELN('Action load assign');
- DELAY(1000);
- {$ENDIF}
-
- ASSIGN(action_file, opt_block.action_fn);
- {$I-}
- RESET(action_file);
- {$I+}
- i := IORESULT;
-
- (*-----------------------------------------------------------------------*)
- (* Free the lock *)
- (*-----------------------------------------------------------------------*)
-
- free_semaphore(semaphore_interrupts);
-
- (*-----------------------------------------------------------------------*)
- (* File doesn't exist. Ooopss *)
- (*-----------------------------------------------------------------------*)
-
- IF i = 2 THEN
- BEGIN;
- send_tnc_data_str('Can''t find file -- ' + opt_block.action_fn + cr);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- IF i <> 0 THEN
- BEGIN;
- send_tnc_data_str('Error opening ' + opt_block.action_fn + cr);
- STR(i, s1);
- send_tnc_data_str('DOS error ' + s1 + cr);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Initialize things *)
- (*-----------------------------------------------------------------------*)
-
- last_msg_action := NIL;
-
- (*-----------------------------------------------------------------------*)
- (* Read thru file *)
- (*-----------------------------------------------------------------------*)
-
- {$IFDEF DEBUG1}
- WRITELN('Action load read loop');
- DELAY(1000);
- {$ENDIF}
-
- WHILE NOT EOF(action_file) DO
- BEGIN;
-
- active_tcb^.error_sw := FALSE;
-
- READLN(action_file, s1);
-
- strip_var(s1, 'B');
-
- (*-------------------------------------------------------------------*)
- (* Get the action word *)
- (*-------------------------------------------------------------------*)
-
- action_word := subword(@s1, 1, 1);
-
- upcase_str_var(action_word);
-
- {$IFDEF DEBUG2}
- WRITELN('Action word -- ', action_word);
- DELAY(1000);
- {$ENDIF}
-
- (*-------------------------------------------------------------------*)
- (* Ignore comments *)
- (*-------------------------------------------------------------------*)
-
- IF (LENGTH(action_word) = 0)
- OR (action_word[1] = '*')
- OR (action_word[1] = ';') THEN
- GOTO iterate;
-
- (*-------------------------------------------------------------------*)
- (* Process "NO" *)
- (*-------------------------------------------------------------------*)
-
- IF COPY(action_word, 1, 2) = 'NO' THEN
- BEGIN;
- action_word := COPY(action_word, 3, 255);
- invert_flag := TRUE;
- END
- ELSE
- invert_flag := FALSE;
-
- (*-------------------------------------------------------------------*)
- (* DENY *)
- (*-------------------------------------------------------------------*)
-
- IF action_word = 'DENY_NEW_MSG' THEN
- BEGIN;
-
- IF NOT execute_load THEN
- GOTO iterate;
-
- IF invert_flag THEN
- build_format0_block
- ELSE
- build_format2_block(0, 9);
-
- new_msg_action^.action_type := action_msg_deny
- OR new_msg_action^.action_type;
- GOTO iterate;
-
- END;
-
- (*-------------------------------------------------------------------*)
- (* HOLD/REJECT/REVIEW *)
- (*-------------------------------------------------------------------*)
-
- IF (action_word = 'HOLD')
- OR (action_word = 'HOLD_OLD')
- OR (action_word = 'REJECT')
- OR (action_word = 'REVIEW') THEN
- BEGIN;
-
- IF NOT execute_load THEN
- GOTO iterate;
-
- build_format0_block;
-
- IF action_word = 'REVIEW' THEN
- BEGIN;
- new_msg_action^.action_type := action_msg_review
- OR new_msg_action^.action_type;
- GOTO iterate;
- END;
-
- new_msg_action^.action_type := action_msg_hold
- OR new_msg_action^.action_type;
-
- IF action_word = 'HOLD_OLD' THEN
- new_msg_action^.action_type := action_msg_old
- OR new_msg_action^.action_type;
-
- IF action_word = 'REJECT' THEN
- new_msg_action^.action_type := action_msg_reject
- OR new_msg_action^.action_type;
-
- GOTO iterate;
-
- END; (*----- End HOLD/REJECT --------------------------------------*)
-
- (*-------------------------------------------------------------------*)
- (* DISTRIBUTE name search *)
- (*-------------------------------------------------------------------*)
-
- IF action_word = 'DISTRIBUTE' THEN
- BEGIN;
-
- IF NOT execute_load THEN
- GOTO iterate;
-
- build_format1_block;
-
- new_msg_action^.action_type := action_msg_distr
- OR new_msg_action^.action_type;
-
- GOTO iterate;
-
- END; (*----- End DISTRIBUTE ---------------------------------------*)
-
- (*-------------------------------------------------------------------*)
- (* NOCHANGE_ADR *)
- (*-------------------------------------------------------------------*)
-
- IF invert_flag AND (action_word = 'CHANGE_ADR') THEN
- BEGIN;
-
- IF NOT execute_load THEN
- GOTO iterate;
-
- build_format0_block;
-
- new_msg_action^.action_type := action_msg_change
- OR new_msg_action^.action_type;
-
- GOTO iterate;
-
- END; (*----- End NOCHANGE_ADR -------------------------------------*)
-
- (*-------------------------------------------------------------------*)
- (* CHANGE_ADR *)
- (*-------------------------------------------------------------------*)
-
- IF action_word = 'CHANGE_ADR' THEN
- BEGIN;
-
- {$IFDEF DEBUG2}
- WRITELN('Action change -- ', s1);
- DELAY(1000);
- {$ENDIF}
-
- IF NOT execute_load THEN
- GOTO iterate;
-
- (*---------------------------------------------------------------*)
- (* Throw away the verb *)
- (*---------------------------------------------------------------*)
-
- s1 := subword(@s1, 2, 0);
-
- (*---------------------------------------------------------------*)
- (* Find the line break and validate *)
- (*---------------------------------------------------------------*)
-
- i := POS(' => ', s1);
-
- {$IFDEF DEBUG4}
- WRITELN('=> look -- ', i, ' -- ', s1);
- DELAY(1000);
- {$ENDIF}
-
- IF i = 0 THEN
- BEGIN;
- send_tnc_data_str('No => in action file -- ' + s1 + cr);
- GOTO ITERATE;
- END;
-
- IF i = 1 THEN
- BEGIN;
- send_tnc_data_str('No search in action file -- ' + s1 + cr);
- GOTO ITERATE;
- END;
-
- (*---------------------------------------------------------------*)
- (* Break the incoming line into two parts -- The search and *)
- (* the change to. *)
- (*---------------------------------------------------------------*)
-
- s2 := COPY(s1, i+4, 255);
- s1 := COPY(s1, 1, i-1);
- strip_var(s1, 'B');
- strip_var(s2, 'B');
-
- {$IFDEF DEBUG4}
- WRITELN('=> split1 -- ', s1);
- WRITELN('=> split2 -- ', s2);
- DELAY(1000);
- {$ENDIF}
-
- (*---------------------------------------------------------------*)
- (* More validation on line break *)
- (*---------------------------------------------------------------*)
-
- IF s2 = '' THEN
- BEGIN;
- send_tnc_data_str('No to address in action file -- ' + s1 + cr);
- GOTO ITERATE;
- END;
-
- IF s1 = '' THEN
- BEGIN;
- send_tnc_data_str('No search in action file -- ' + s1 + cr);
- GOTO ITERATE;
- END;
-
- (*---------------------------------------------------------------*)
- (* Test the search string *)
- (*---------------------------------------------------------------*)
-
- test_search;
- IF active_tcb^.error_sw THEN
- GOTO iterate;
-
- (*---------------------------------------------------------------*)
- (* Reset any left over address *)
- (*---------------------------------------------------------------*)
-
- WITH active_tcb^.curr_msg.msg_i_mb DO
- BEGIN;
- msg_to := '';
- msg_to_at := '';
- msg_to_h := '';
- END;
-
- (*---------------------------------------------------------------*)
- (* Break up the address *)
- (*---------------------------------------------------------------*)
-
- WITH active_tcb^.curr_msg.msg_i_mb DO
- send_msg_to_process(s2);
- IF active_tcb^.error_sw THEN
- BEGIN;
- send_tnc_data_str('Bad address in action file -- ' + s2 + cr);
- GOTO ITERATE;
- END;
-
- {$IFDEF DEBUG4}
- WITH active_tcb^.curr_msg.msg_i_mb DO
- BEGIN;
- WRITELN('TO -- ', msg_to);
- WRITELN('TO@ -- ', msg_to_at);
- WRITELN('TO. -- ', msg_to_h);
- DELAY(1000);
- END;
- {$ENDIF}
-
- (*---------------------------------------------------------------*)
- (* Build the to address string. This is three strings butted *)
- (* against each other *)
- (*---------------------------------------------------------------*)
-
- WITH active_tcb^.curr_msg.msg_i_mb DO
- BEGIN;
-
- s2 := msg_to;
-
- {$IFDEF DEBUG4}
- WRITELN('Cto -- ', 1, ' -- ', s2);
- {$ENDIF}
-
- i := LENGTH(s2) + 1;
- str_ptr := ADDR(s2[i]);
-
- IF msg_to_at = 'NONE' THEN
- str_ptr^ := ''
- ELSE
- str_ptr^ := msg_to_at;
-
- {$IFDEF DEBUG4}
- WRITELN('Cto@ -- ', i, ' -- ', str_ptr^);
- {$ENDIF}
-
- i := i + LENGTH(str_ptr^) + 1;
- str_ptr := ADDR(s2[i]);
-
- IF msg_to_h = 'NONE' THEN
- str_ptr^ := ''
- ELSE
- str_ptr^ := msg_to_h;
-
- {$IFDEF DEBUG4}
- WRITELN('Cto. -- ', i, ' -- ', str_ptr^);
- {$ENDIF}
-
- INC(i, LENGTH(str_ptr^) + 1);
-
- END;
-
- (*---------------------------------------------------------------*)
- (* Build a new action block *)
- (*---------------------------------------------------------------*)
-
- j := action_msg_overhead + 1 + LENGTH(s1) + i;
- GETMEM(new_msg_action, j);
- FILLCHAR(new_msg_action^, j, #0);
-
- {$IFDEF DEBUG3}
- trace_data('ACC', j, new_msg_action, s1);
- {$ENDIF}
-
- new_msg_action^.next_action := NIL;
- new_msg_action^.action_type := action_msg_change;
-
- new_msg_action^.action_info := s1;
-
- str_ptr := ADDR(new_msg_action^.action_info[LENGTH(s1) + 1]);
- MOVE(s2, str_ptr^, i);
-
- (*---------------------------------------------------------------*)
- (* Copy over the search info *)
- (*---------------------------------------------------------------*)
-
- copy_search_blocks;
-
- (*---------------------------------------------------------------*)
- (* Chain the block on the end of the list *)
- (*---------------------------------------------------------------*)
-
- IF last_msg_action = NIL THEN
- first_msg_action := new_msg_action
- ELSE
- last_msg_action^.next_action := new_msg_action;
-
- last_msg_action := new_msg_action;
-
- (*---------------------------------------------------------------*)
- (* Done *)
- (*---------------------------------------------------------------*)
-
- {$IFDEF DEBUG2}
- WRITELN('Action change loaded');
- WRITELN(new_msg_action^.action_info);
- i := LENGTH(new_msg_action^.action_info) + 1;
- str_ptr := ADDR(new_msg_action^.action_info[i]);
- WRITELN(LENGTH(str_ptr^), '=',str_ptr^);
- INC(i, LENGTH(str_ptr^) + 1);
- str_ptr := ADDR(new_msg_action^.action_info[i]);
- WRITELN(LENGTH(str_ptr^), '=',str_ptr^);
- INC(i, LENGTH(str_ptr^) + 1);
- str_ptr := ADDR(new_msg_action^.action_info[i]);
- WRITELN(LENGTH(str_ptr^), '=',str_ptr^);
- DELAY(1000);
- {$ENDIF}
-
- GOTO iterate;
-
- END; (*----- End CHANGE_ADR ---------------------------------------*)
-
- (*-------------------------------------------------------------------*)
- (* MAKE_FILE *)
- (*-------------------------------------------------------------------*)
-
- IF (action_word = 'MAKE_FILE')
- OR (action_word = 'MAKE_FILE_REPLACE')
- OR (action_word = 'MAKE_FILE_APPEND') THEN
- BEGIN;
-
- IF NOT execute_make THEN
- GOTO iterate;
-
- {$IFDEF DEBUG2}
- WRITELN('Action makefile -- ', s1);
- DELAY(1000);
- {$ENDIF}
-
- {$IFDEF DEBUG5}
- WRITELN('Action makefile 1 -- ', s1);
- DELAY(1000);
- {$ENDIF}
-
- options_str := get_option_string(s1);
-
- {$IFDEF DEBUG5}
- WRITELN('Action makefile 2 -- ', s1);
- DELAY(1000);
- {$ENDIF}
-
- validate_format1_statement;
-
- IF NOT active_tcb^.error_sw THEN
- do_make_file;
-
- GOTO iterate;
-
- END; (*----- End MAKE_FILE ----------------------------------------*)
-
- (*-------------------------------------------------------------------*)
- (* CLEAN_MSGS *)
- (*-------------------------------------------------------------------*)
-
- IF action_word = 'CLEAN_MSGS' THEN
- BEGIN;
-
- IF NOT execute_clean THEN
- GOTO iterate;
-
- {$IFDEF DEBUG2}
- WRITELN('Action makefile -- ', s1);
- DELAY(1000);
- {$ENDIF}
-
- validate_format1_statement;
-
- IF NOT active_tcb^.error_sw THEN
- do_clean;
-
- GOTO iterate;
-
- END; (*----- End CLEAN_MSGS ---------------------------------------*)
-
- (*-------------------------------------------------------------------*)
- (* Error *)
- (*-------------------------------------------------------------------*)
-
- {$IFDEF DEBUG2}
- WRITELN('Action bad word -- ', action_word);
- DELAY(1000);
- {$ENDIF}
-
- send_tnc_data_str('Bad word in action file -- ' + action_word + cr);
-
- (*-------------------------------------------------------------------*)
- (* Loop end... *)
- (*-------------------------------------------------------------------*)
-
- iterate:
-
- END; (*----- End loop thru the file -----------------------------------*)
-
- (*-----------------------------------------------------------------------*)
- (* Done. *)
- (*-----------------------------------------------------------------------*)
-
- CLOSE(action_file);
-
- (*-----------------------------------------------------------------------*)
- (* Tell user done *)
- (*-----------------------------------------------------------------------*)
-
- send_tnc_data_str('Action processing is complete' + cr);
-
- END;